import 'package:flutter/material.dart';
import 'package:kxy_flutter_app/components/refresh_header.dart';
import 'package:kxy_flutter_app/r.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class EmptyWidget extends StatelessWidget {
  final Future Function() onRefresh;
  final refreshController = new RefreshController();
  EmptyWidget({Key key, this.onRefresh}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SmartRefresher(
      controller: refreshController,
      header: RefreshHeader(),
      enablePullUp: false,
      enablePullDown: onRefresh != null,
      onRefresh: () async {
        await onRefresh();
        refreshController.refreshCompleted();
      },
      child: Container(
        width: MediaQuery.of(context).size.width,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Padding(
              padding: EdgeInsets.only(bottom: 10),
              child: Image.asset(
                R.assetsCommonNoData,
                width: MediaQuery.of(context).size.width / 2,
              ),
            ),
            Text(
              '没有任何数据',
              style: TextStyle(
                fontSize: 16,
                color: Colors.black54,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
